home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 September / macformat-004.iso / Shareware City / Graphics / MacAnim_Viewer_1.0.1 Folder / File Formats ƒ / FLI Format next >
Encoding:
Text File  |  1993-11-18  |  6.7 KB  |  172 lines  |  [TEXT/KAHL]

  1. FLI FORMAT
  2. ----------
  3. >From: kdarling@hobbes.ncsu.edu (Kevin Darling)
  4.  
  5. Autodesk Animator files explanation (.FLI only excerpted).  I believe
  6. that the original programmer wrote up this doc.  It's correct, as I've
  7. used the info to realtime playback stock .FLIs on a 680x0 machine.
  8. All numbers in a .FLI file are in Intel format, so you may have to
  9. compensate for that, of course. - kevin
  10.  
  11. 8.1 Flic Files (.FLI)
  12.  
  13.      The details of a FLI file are moderately complex, but the
  14. idea behind it is simple: don't bother storing the parts of a
  15. frame that are the same as the last frame.  Not only does this
  16. save space, but it's very quick.  It's faster to leave a pixel
  17. alone than to set it.
  18.  
  19.      A FLI file has a 128-byte header followed by a sequence of
  20. frames. The first frame is compressed using a bytewise run-length
  21. compression scheme.  Subsequent frames are stored as the
  22. difference from the previous frame.  (Occasionally the first
  23. frame and/or subsequent frames are uncompressed.)  There is one
  24. extra frame at the end of a FLI which contains the difference
  25. between the last frame and the first frame.
  26.  
  27.      The FLI header:
  28.  
  29.      byte size name      meaning
  30.      offset
  31.  
  32.      0    4    size      Length of file, for programs that want
  33.                          to read the FLI all at once if possible.
  34.      4    2    magic     Set to hex AF11.  Please use another
  35.                          value here if you change format (even to
  36.                          a different resolution) so Autodesk
  37.                          Animator won't crash trying to read it.
  38.      6    2    frames    Number of frames in FLI.  FLI files have
  39.                          a maxium length of 4000 frames.
  40.      8    2    width     Screen width (320).
  41.      10   2    height    Screen height (200).
  42.      12
  43.      14   2    flags     Must be 0.
  44.      16   2    speed     Number of video ticks between frames.
  45.      18   4    next      Set to 0.
  46.      22   4    frit      Set to 0.
  47.      26   102  expand    All zeroes -- for future enhancement.
  48.  
  49.      Next are the frames, each of which has a header:
  50.  
  51.      byte size name      meaning
  52.      offset
  53.      0    4    size      Bytes in this frame.  Autodesk Animator
  54.                          demands that this be less than 64K.
  55.      4    2    magic     Always hexadecimal F1FA
  56.      6    2    chunks    Number of 'chunks' in frame.
  57.      8    8    expand    Space for future enhancements. All zeros.
  58.  
  59.      After the frame header come the chunks that make up the
  60. frame.  First comes a color chunk if the color map has changed
  61. from the last frame.  Then comes a pixel chunk if the pixels have
  62. changed.  If the frame is absolutely identical to the last frame
  63. there will be no chunks at all.
  64.  
  65.      A chunk itself has a header, followed by the data.  The
  66. chunk header is:
  67.  
  68.      byte size name meaning
  69.      offset
  70.      0    4    size Bytes in this chunk.
  71.      4    2    type Type of chunk (see below).
  72.  
  73.      There are currently five types of chunks you'll see in a FLI
  74. file:
  75.  
  76.      number    name      meaning
  77.      11        FLI_COLOR Compressed color map
  78.      12        FLI_LC    Line compressed -- the most common type
  79.                          of compression for any but the first
  80.                          frame.  Describes the pixel difference
  81.                          from the previous frame.
  82.      13        FLI_BLACK Set whole screen to color 0 (only occurs
  83.                          on the first frame).
  84.      15        FLI_BRUN  Bytewise run-length compression -- first
  85.                          frame only
  86.      16        FLI_COPY  Indicates uncompressed 64000 bytes soon
  87.                          to follow.  For those times when
  88.                          compression just doesn't work!
  89.  
  90.      The compression schemes are all byte-oriented.  If the
  91. compressed data ends up being an odd length a single pad byte is
  92. inserted so that the FLI_COPY's always start at an even address
  93. for faster DMA.
  94.  
  95. FLI_COLOR Chunks
  96.  
  97.      The first word is the number of packets in this chunk. This
  98. is followed directly by the packets.  The first byte of a packet
  99. says how many colors to skip.  The next byte says how many colors
  100. to change.  If this byte is zero it is interpreted to mean 256. 
  101. Next follows 3 bytes for each color to change (one each for red,
  102. green and blue).
  103.  
  104. FLI_LC Chunks
  105.  
  106.      This is the most common, and alas, most complex chunk.   The
  107. first word (16 bits) is the number of lines starting from the top
  108. of the screen that are the same as the previous frame. (For
  109. example, if there is motion only on the bottom line of screen
  110. you'd have a 199 here.)  The next word is the number of lines
  111. that do change.  Next there is the data for the changing lines
  112. themselves.  Each line is compressed individually; among other
  113. things this makes it much easier to play back the FLI at a
  114. reduced size.
  115.  
  116.      The first byte of a compressed line is the number of packets
  117. in this line.  If the line is unchanged from the last frame this 
  118. is zero.  The format of an individual packet is:
  119.  
  120.  skip_count
  121.  size_count
  122.  data
  123.  
  124.      The skip count is a single byte.  If more than 255 pixels
  125. are to be skipped it must be broken into 2 packets. The size
  126. count is also a byte.  If it is positive, that many bytes of data
  127. follow and are to be copied to the screen.  If it's negative a
  128. single byte follows, and is repeated -skip_count times.
  129.  
  130.      In the worst case a FLI_LC frame can be about 70K.  If it
  131. comes out to be 60000 bytes or more Autodesk Animator decides
  132. compression isn't worthwhile and saves the frame as FLI_COPY.
  133.  
  134. FLI_BLACK Chunks
  135.  
  136.      These are very simple.  There is no data associated with
  137. them at all. In fact they are only generated for the first frame
  138. in Autodesk Animator after the user selects NEW under the FLIC menu.
  139.  
  140. FLI_BRUN Chunks
  141.  
  142.      These are much like FLI_LC chunks without the skips.  They
  143. start immediately with the data for the first line, and go line-
  144. by-line from there.  The first byte contains the number of
  145. packets in that line.  The format for a packet is:
  146.  
  147.  size_count
  148.  data
  149.  
  150.      If size_count is positive the data consists of a single byte
  151. which is repeated size_count times. If size_count is negative
  152. there are -size_count bytes of data which are copied to the
  153. screen. In Autodesk Animator if the "compressed" data shows signs
  154. of exceeding 60000 bytes the frame is stored as FLI_COPY instead.
  155.  
  156. FLI_COPY Chunks
  157.  
  158.      These are 64000 bytes of data for direct reading onto the
  159. screen.
  160.  
  161.  -eof-
  162.  
  163. Notes: Since these are animations, the last frame will delta into a
  164. copy of the first one (which was usually a large BRUN chunk).  Therefore,
  165. looping should go back to the _second_ frame chunk (usually a LC
  166. or COLOR chunk) instead of all the way back to the file beginning, to
  167. avoid a "stutter" caused by unnecessarily redecoding the original frame.
  168. Also, a very few files may have palette animation, so write your code
  169. so that COLOR chunks can be found at any time.  - kevin
  170.  
  171.  
  172.